﻿using BW.MesProject.Equipment.Domain.Equipment;
using BW.MesProject.Equipment.Infrastructure.Dto.Input.DeviceType;
using BW.MesProject.Equipment.Infrastructure.Dto.Output.DeviceType;
using BW.MesProject.Equipment.Infrastructure.Equipment;
using BW.MesProject.Public.ErrorCode;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.MesProject.Equipment.Host.Controllers
{
    /// <summary>
    /// 设备类型控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DeviceTypeController : ControllerBase
    {
        private readonly IDeviceTypeService _deviceTypeService;

        public DeviceTypeController(IDeviceTypeService deviceTypeService)
        {
            this._deviceTypeService = deviceTypeService;
        }
        /// <summary>
        /// 新增设备类型接口
        /// </summary>
        /// <param name="input">设备类型新增输入参数</param>
        /// <returns>返回操作结果，包含新增设备类型的主键ID</returns>
        [HttpPost]
        public ApiResult<int> AddDeviceType([FromBody] AddDeviceTypeInput input)
        {
            return _deviceTypeService.AddDeviceType(input);
        }

        /// <summary>
        /// 获取设备类型列表接口
        /// </summary>
        /// <param name="input">设备类型列表输入参数</param>
        /// <returns>返回设备类型列表</returns>
        [HttpGet]
        public ApiPaging<DeviceTypeOutput> GetDeviceTypeList([FromQuery] DeviceTypeInput input)
        {
            return _deviceTypeService.GetDeviceTypeList(input);
        }
        /// <summary>
        /// 修改设备类型接口
        /// </summary>
        /// <param name="input">设备类型修改输入参数</param>
        /// <returns>返回操作结果，包含受影响的行数</returns>
        [HttpPut]
        public ApiResult<int> UpdateDeviceType(UpdateDeviceTypeInput input)
        {
            return _deviceTypeService.UpdateDeviceType(input);
        }

        /// <summary>
        /// 逻辑删除设备类型接口
        /// </summary>
        /// <param name="id">设备类型主键ID</param>
        /// <returns>返回操作结果，包含受影响的行数</returns>
        [HttpDelete]
        public ApiResult<int> DeleteDeviceType([FromQuery] long id)
        {
            return _deviceTypeService.DeleteDeviceType(id);
        }

        /// <summary>
        /// 根据设备编号获取设备类型信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<DeviceTypeOutput> GetDeviceTypeValue([FromQuery]long id)
        {
            return _deviceTypeService.GetDeviceTypeValue(id);
        }
    }
}
